﻿using ChikovMF.Application.Features.Projects.Shared;
using ChikovMF.Entities;
using MediatR;

namespace ChikovMF.Application.Features.Projects.CreateProject;

public class CreateProjectCommand : ProjectModel, IRequest<Guid>
{
    internal Project CreateProject()
    {
        return new Project
        {
            Name = this.Name,
            Description = this.Description,
            Content = this.Content,

            Links = this.Links?.Select(l => new Link
            {
                Name = l.Name,
                Url = l.Url
            }).ToList(),

            TagLinks = this.Tags?.Select(t => new ProjectTag
            {
                Order = t.Order,
                TagId = t.TagId
            }).ToList(),
        };
    }
}
